const {fork}=require("child_process")

let childProcess=fork("fork-child.js")

let index=0;
let intervalId=setInterval(()=>{
    childProcess.send("this is a msg from parent process"+index);
    index++;
    if(index==10){
        clearInterval(intervalId)
    }
},1000)

childProcess.on("message",(msg)=>{
    console.log(msg)
})